Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example: construct guest resource #24

Merged
merged 12 commits into from
Jan 16, 2025

Conversation

DougAnderson444
Copy link
Contributor

Construct guest resource example

  • uses Value::Bool(false) as results placeholder
  • reverted pub to pub(crate) as no it's not necessary

Closes #23

@DougAnderson444 DougAnderson444 changed the title Guest resource add example: construct guest resource Jan 15, 2025
Copy link
Owner

@DouglasDwyer DouglasDwyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this example - I had a few small questions/comments on PR structure, but after they are addressed I will merge it :)

rust-toolchain.toml Outdated Show resolved Hide resolved
@@ -0,0 +1,440 @@
#[allow(dead_code)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks autogenerated. Should we rely on a macro to generate and include these bindings rather than including their expanded version in the repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the latest way of doing things with wit-bindgen-rt, as per the cargo-component template.

But that said, I did just try it as the wit-bindgen way, and that works too. If you prefer the examples to be consistent with each other, we can go with:

wit_bindgen::generate!({
    path: "wit/world.wit"
});

export!(Component);

//..

I'm not fussed either way, happy to commit ^^^ those change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I used the latest version of wit-bindgen so the api is a bit different, but same effect.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, let's stick with this because it is simpler and wit_bindgen also appears to be well-supported. Users concerned about compile times and dependencies can use the bindings.rs solution in their own projects. For an example it's better to be simpler :)

examples/guest_resource/.vscode/settings.json Outdated Show resolved Hide resolved
@DougAnderson444
Copy link
Contributor Author

@DouglasDwyer thanks for the feedback! I addressed your issues, committed them, cleaned up a couple other dead code lines, and even learned a few new things myself along the way.

If you spot anything else pls let me know.

@DouglasDwyer DouglasDwyer merged commit d927357 into DouglasDwyer:master Jan 16, 2025
@DouglasDwyer
Copy link
Owner

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add example: construct guest resource
2 participants